
<h1><span class="yiyi-st" id="yiyi-12">numpy.testing.assert_array_less</span></h1>
        <blockquote>
        <p>原文：<a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.testing.assert_array_less.html">https://docs.scipy.org/doc/numpy/reference/generated/numpy.testing.assert_array_less.html</a></p>
        <p>译者：<a href="https://github.com/wizardforcel">飞龙</a> <a href="http://usyiyi.cn/">UsyiyiCN</a></p>
        <p>校对：（虚位以待）</p>
        </blockquote>
    
<dl class="function">
<dt id="numpy.testing.assert_array_less"><span class="yiyi-st" id="yiyi-13"> <code class="descclassname">numpy.testing.</code><code class="descname">assert_array_less</code><span class="sig-paren">(</span><em>x</em>, <em>y</em>, <em>err_msg=&apos;&apos;</em>, <em>verbose=True</em><span class="sig-paren">)</span><a class="reference external" href="http://github.com/numpy/numpy/blob/v1.11.3/numpy/testing/utils.py#L921-L990"><span class="viewcode-link">[source]</span></a></span></dt>
<dd><p><span class="yiyi-st" id="yiyi-14">如果两个array_like对象的排序不小于，则引发AssertionError。</span></p>
<p><span class="yiyi-st" id="yiyi-15">给定两个array_like对象，检查形状是否相等，第一个对象的所有元素都严格小于第二个对象的所有元素。</span><span class="yiyi-st" id="yiyi-16">在形状不匹配或不正确的有序值时引发异常。</span><span class="yiyi-st" id="yiyi-17">如果对象具有零维度，则不会引发形状不匹配。</span><span class="yiyi-st" id="yiyi-18">与numpy中的标准用法相比，NaNs被比较，如果两个对象在相同位置具有NaN，则不提出断言。</span></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name">
<col class="field-body">
<tbody valign="top">
<tr class="field-odd field"><th class="field-name"><span class="yiyi-st" id="yiyi-19">参数：</span></th><td class="field-body"><p class="first"><span class="yiyi-st" id="yiyi-20"><strong>x</strong>：array_like</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-21">检查较小的对象。</span></p>
</div></blockquote>
<p><span class="yiyi-st" id="yiyi-22"><strong>y</strong>：array_like</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-23">要比较的较大对象。</span></p>
</div></blockquote>
<p><span class="yiyi-st" id="yiyi-24"><strong>err_msg</strong>：string</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-25">出现故障时打印的错误消息。</span></p>
</div></blockquote>
<p><span class="yiyi-st" id="yiyi-26"><strong>verbose</strong>：bool</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-27">如果为True，则冲突的值将附加到错误消息。</span></p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name"><span class="yiyi-st" id="yiyi-28">上升：</span></th><td class="field-body"><p class="first"><span class="yiyi-st" id="yiyi-29"><strong>AssertionError</strong></span></p>
<blockquote class="last">
<div><p><span class="yiyi-st" id="yiyi-30">如果实际和所需对象不相等。</span></p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title"><span class="yiyi-st" id="yiyi-31">也可以看看</span></p>
<dl class="last docutils">
<dt><span class="yiyi-st" id="yiyi-32"><a class="reference internal" href="numpy.testing.assert_array_equal.html#numpy.testing.assert_array_equal" title="numpy.testing.assert_array_equal"><code class="xref py py-obj docutils literal"><span class="pre">assert_array_equal</span></code></a></span></dt>
<dd><span class="yiyi-st" id="yiyi-33">测试对象是否相等</span></dd>
<dt><span class="yiyi-st" id="yiyi-34"><a class="reference internal" href="numpy.testing.assert_array_almost_equal.html#numpy.testing.assert_array_almost_equal" title="numpy.testing.assert_array_almost_equal"><code class="xref py py-obj docutils literal"><span class="pre">assert_array_almost_equal</span></code></a></span></dt>
<dd><span class="yiyi-st" id="yiyi-35">测试对象的相等性达到精度</span></dd>
</dl>
</div>
<p class="rubric"><span class="yiyi-st" id="yiyi-36">例子</span></p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">testing</span><span class="o">.</span><span class="n">assert_array_less</span><span class="p">([</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">nan</span><span class="p">],</span> <span class="p">[</span><span class="mf">1.1</span><span class="p">,</span> <span class="mf">2.0</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">nan</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">testing</span><span class="o">.</span><span class="n">assert_array_less</span><span class="p">([</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">nan</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mf">2.0</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">nan</span><span class="p">])</span>
<span class="gp">...</span>
<span class="go">&lt;type &apos;exceptions.ValueError&apos;&gt;:</span>
<span class="go">Arrays are not less-ordered</span>
<span class="go">(mismatch 50.0%)</span>
<span class="go"> x: array([  1.,   1.,  NaN])</span>
<span class="go"> y: array([  1.,   2.,  NaN])</span>
</pre></div>
</div>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">testing</span><span class="o">.</span><span class="n">assert_array_less</span><span class="p">([</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">4.0</span><span class="p">],</span> <span class="mi">3</span><span class="p">)</span>
<span class="gp">...</span>
<span class="go">&lt;type &apos;exceptions.ValueError&apos;&gt;:</span>
<span class="go">Arrays are not less-ordered</span>
<span class="go">(mismatch 50.0%)</span>
<span class="go"> x: array([ 1.,  4.])</span>
<span class="go"> y: array(3)</span>
</pre></div>
</div>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">testing</span><span class="o">.</span><span class="n">assert_array_less</span><span class="p">([</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">2.0</span><span class="p">,</span> <span class="mf">3.0</span><span class="p">],</span> <span class="p">[</span><span class="mi">4</span><span class="p">])</span>
<span class="gp">...</span>
<span class="go">&lt;type &apos;exceptions.ValueError&apos;&gt;:</span>
<span class="go">Arrays are not less-ordered</span>
<span class="go">(shapes (3,), (1,) mismatch)</span>
<span class="go"> x: array([ 1.,  2.,  3.])</span>
<span class="go"> y: array([4])</span>
</pre></div>
</div>
</dd></dl>
